package cl.regalloc.parse;

/**
 * Register class implementing operand interface
 * @author andyli
 *
 */

public class Register implements Operand {

	private String registerName;
	private Boolean isVirtual;
	private Boolean isDirty;

	public Register(String registerName) {
		this.registerName = registerName;
		this.isVirtual = false;
		this.isDirty = false;
	}

	public Register(String registerName, Boolean isVirtual) {
		this.registerName = registerName;
		this.isVirtual = isVirtual;
		this.isDirty = false;
	}

	public Boolean isVirtual() {
		return this.isVirtual;
	}

	public Boolean isDirty() {
		return this.isDirty;
	}

	public void setDirty() {
		this.isDirty = true;
	}

	public String toString() {
		if (this.isVirtual) {
			return ("v" + this.registerName);
		} else {
			return this.registerName;
		}
	}

	public void setColour(Integer colour) {
		this.registerName = "$" + colour.toString();
		this.isVirtual = false;
	}
}
